
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Manage Diet Page</title>
        <script type="text/javascript" >
            function exportmasterfile()
            {   var url='${pageContext.request.contextPath}/xml/Diets.pdf';
                window.open(url,'Download');
            }
        </script>
    </head>
    <body>

        <jsp:include page="adminHeader.jsp"/>
        <form action="ControllerServlet" method="POST">
            Diet's Name: <input type="text" name="txtDietName" value="" />
            <input type="submit" value="SearchDiet" name="btnAction" />
        </form>
        <input type="button" value="CreatePDF" name="btnAction" onclick=exportmasterfile() />
        <div>
            <c:choose>
                <c:when test="${empty sessionScope.resultsDiet }">
                    <h2>Diet not found</h2>
                </c:when>
                    <c:otherwise>
                        <display:table name="sessionScope.resultsDiet" pagesize="5"
                                       export="false" sort="list" id="row" >
                            <display:column property="dietID" title="DietID"
                                            sortable="true" headerClass="sortable" />
                            <display:column property="customerID" title="CustomerID"
                                            sortable="true" headerClass="sortable" />
                            <display:column property="dateTimeBegin" title="Date Begin"
                                            sortable="true" headerClass="sortable" />
                            <display:column property="dateTimeEnd" title="Date End"
                                            sortable="true" headerClass="sortable" />
                            <display:column property="dietName" title="Diet Name"
                                            sortable="true" headerClass="sortable" />
                            <display:column property="calorieNeed" title="Calorie Need"
                                            sortable="true" headerClass="sortable" />
                            <display:column property="isNew" title="New"
                                            sortable="true" headerClass="sortable" />
                            <display:column> <a href="viewDietDetail?btnAction=viewDietDetail&id=${row.dietID}">View Detail</a>
                            </display:column>
                        </display:table>
                    </c:otherwise>
            </c:choose>
        </div>

    </body>
</html>

